//
//  AboutViewController.m
//  Crocodile
//
//  Created by tin vu on 8/29/12.
//  Copyright (c) 2012 hust. All rights reserved.
//

#import "AboutViewController.h"
#import "Constant.h"

@interface AboutViewController ()

@end

@implementation AboutViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    // Background image
    UIImage *backgroundImg = [UIImage imageNamed:kImgBackground];
    UIImageView *backgroundImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    [backgroundImgView setImage:backgroundImg];
    backgroundImgView.alpha = 0.5;
    [self.view addSubview:backgroundImgView];
    [backgroundImg release];
    [backgroundImgView release];
    
    // Header Image
    UIImage *headerImg = [UIImage imageNamed:kImgHeader];
    UIImageView *headerImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    [headerImgView setImage:headerImg];
    [self.view addSubview:headerImgView];
    [headerImg release];
    [headerImgView release];
    
    // Title
    UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 3, 170, 34)];
    titleLbl.backgroundColor = [UIColor clearColor];
    titleLbl.center = CGPointMake(160, 20);
    titleLbl.textAlignment = UITextAlignmentCenter;
    titleLbl.textColor = [UIColor greenColor];
    titleLbl.font = [UIFont boldSystemFontOfSize:20];
    titleLbl.text = kStrAboutTabTitle;
    [self.view addSubview:titleLbl];
    [titleLbl release];
    
    // Content
    // Brand image
    UIImage *brandImg = [UIImage imageNamed:kImgBrand];
    UIImageView *brandImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
    brandImgView.center = CGPointMake(160, 200);
    [brandImgView setImage:brandImg];
    brandImgView.alpha = 0.5;
    [self.view addSubview:brandImgView];
    [brandImg release];
    [brandImgView release];
    
    // Content text
    UIWebView *contentWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 45, 320, 365)];
    NSString* fileString = [[NSBundle mainBundle] pathForResource:@"info" ofType:@"html"];
    NSString* htmlString = [NSString stringWithContentsOfFile:fileString encoding:NSUTF8StringEncoding error:nil];
    contentWebView.backgroundColor = [UIColor clearColor];
    [contentWebView loadHTMLString:htmlString baseURL:nil];
    [self.view addSubview:contentWebView];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
